package com.west_traveler.viewpager_adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.west_traveler.entity.entity_editor.Discovery;
import com.west_traveler.entity.entity_editor.PerProject;
import com.west_traveler.find_page_fragment.findpageheaddragment.FindPageHeadDiscoveryFragment;

import java.util.List;

/**
 * Description:
 * created at 2016/12/6 9:42
 *
 * @author: 黄昌友
 */

public class FindPageHeadDiscoveryViewPagerAdapter extends FragmentStatePagerAdapter {

    private List<PerProject> list;

    public FindPageHeadDiscoveryViewPagerAdapter(FragmentManager fm, Discovery discovery) {
        super(fm);
        list = discovery.getList();
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return FindPageHeadDiscoveryFragment.getInstance(list.get(0), list.get(1), list.get(2), list.get(3));
        }
        if (position == 1) {
            return FindPageHeadDiscoveryFragment.getInstance(list.get(4), list.get(5), list.get(6), list.get(7));
        }
        return null;
    }

    @Override
    public int getCount() {
        return list.size() / 4;
    }
}
